package com.drg.center.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.drg.center.entity.DrgPatientCaseOperationPO;
import com.drg.center.mapper.DrgPatientCaseOperationMapper;
import com.guaike.core.mybatis.plugins.BaseDAO;
import org.springframework.stereotype.Repository;

@Repository
public class DrgPatientCaseOperationDAO extends BaseDAO<DrgPatientCaseOperationMapper, DrgPatientCaseOperationPO> {

    public DrgPatientCaseOperationPO findMainOne(String caseCode) {
        LambdaQueryWrapper<DrgPatientCaseOperationPO> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(DrgPatientCaseOperationPO::getCaseCode, caseCode);
        queryWrapper.eq(DrgPatientCaseOperationPO::getIsMain, Boolean.TRUE);
        queryWrapper.orderByAsc(DrgPatientCaseOperationPO::getId);
        queryWrapper.last("limit 0,1");
        return getBaseMapper().selectOne(queryWrapper);
    }
}
